package com.ruoyi.system.service.impl;

import java.util.List;

import com.ruoyi.common.core.domain.entity.SysProperty;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.system.domain.SysPropertyContract;
import com.ruoyi.system.mapper.SysPropertyContractMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.SysPropertyMapper;
import com.ruoyi.system.service.ISysPropertyService;

/**
 * 房源信息Service业务层处理
 * 
 * @author ssd
 * @date 2024-03-25
 */
@Service
public class SysPropertyServiceImpl implements ISysPropertyService 
{
    @Autowired
    private SysPropertyMapper sysPropertyMapper;
    @Autowired
    private SysPropertyContractMapper sysPropertyContractMapper;


    /**
     * 查询房源信息
     *
     * @param propertyId 房源信息主键
     * @return 房源信息
     */
    @Override
    public SysProperty selectSysPropertyByPropertyId(Long propertyId)
    {
        return sysPropertyMapper.selectSysPropertyByPropertyId(propertyId);
    }

    /**
     * 查询房源信息列表
     * 
     * @param sysProperty 房源信息
     * @return 房源信息
     */
    @Override
    public List<SysProperty> selectSysPropertyList(SysProperty sysProperty)
    {
        return sysPropertyMapper.selectSysPropertyList(sysProperty);
    }

    /**
     * 新增房源信息
     * 
     * @param sysProperty 房源信息
     * @return 结果
     */
    @Override
    public int insertSysProperty(SysProperty sysProperty)
    {
        return sysPropertyMapper.insertSysProperty(sysProperty);
    }

    /**
     * 修改房源信息
     * 
     * @param sysProperty 房源信息
     * @return 结果
     */
    @Override
    public int updateSysProperty(SysProperty sysProperty)
    {
        sysProperty.setUpdateTime(DateUtils.getNowDate());
        SysPropertyContract sysPropertyContract = new SysPropertyContract();
        sysPropertyContract.setPropertyId(sysProperty.getPropertyId());
        sysPropertyContract.setContractId(sysProperty.getContractId());
        sysPropertyContractMapper.updateSysPropertyContract(sysPropertyContract);
        return sysPropertyMapper.updateSysProperty(sysProperty);
    }

    /**
     * 批量删除房源信息
     * 
     * @param propertyIds 需要删除的房源信息主键
     * @return 结果
     */
    @Override
    public int deleteSysPropertyByPropertyIds(Long[] propertyIds)
    {
        sysPropertyContractMapper.deleteSysPropertyContractByPropertyIds(propertyIds);
        return sysPropertyMapper.deleteSysPropertyByPropertyIds(propertyIds);
    }

    /**
     * 删除房源信息信息
     * 
     * @param propertyId 房源信息主键
     * @return 结果
     */
    @Override
    public int deleteSysPropertyByPropertyId(Long propertyId)
    {
        sysPropertyContractMapper.deleteSysPropertyContractByPropertyId(propertyId);
        return sysPropertyMapper.deleteSysPropertyByPropertyId(propertyId);
    }
}
